In addition to recording audio, mediarecoder can also be used to record a video. The procedure is basically the same as that of the recorded audio. However, to record a video, you must not only collect the sound but also the image, you need to use surfaceview to preview and display the image. The following is a simple example. The Code is as follows:
Activity:
Package COM. home. recordvideo; import Java. io. file; import android. app. activity; import android. media. mediarecorder; import androi
()
+ Mediastore. recorder_path_phone;
Sound Recorder and player:
Mediarecorder mrecorder = NULL;
Mediaplayer mplayer = NULL;
Method:
Operations on the status:
State (); setstate (); \\read status and set status
Savestate (); restorestate (); \ stores and reads the storage path
Samplelength (); samplefile (); getsamplefileuri (); returns the corresponding member
Setsamplefileuri (); \ sets the file path
Setsaveinsdcard (); \ save to SD card
Setsave
; // system video File videoFile; MediaRecorder mRecorder; // display SurfaceView sView for video preview; // record whether recording is in progress private boolean isRecording = false; @ Overridepublic void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); // remove the title bar, which must be placed before setContentView (Window. FE ATURE_NO_TITLE); setContentView (R. layout. main); // set setRequestedOrientation (Activit
()
+ MediaStore. RECORDER_PATH_PHONE;
Sound Recorder and player:
MediaRecorder mRecorder = null;
MediaPlayer mPlayer = null;
Method:
Operations on the status:
State (); setState (); \\read status and set status
SaveState (); restoreState (); \ stores and reads the storage path
SampleLength (); sampleFile (); getSampleFileUri (); returns the corresponding member
SetSampleFileUri (); \ sets the file path
SetSaveInSDCard (); \ save to SD card
SetSave
. getExternalStorageDirectory (). getAbsolutePath () + "/oschina/audio"; // The root path of the audio recording file private String mAudioPath; // the path of the audio to be played private boolean mIsRecording; // whether the recording is private boolean mIsPlaying; // whether the private OnPlayListener listener is being played; // initialize the recorder pr Ivate void initRecorder () {mRecorder = new MediaRecorder ();
. ACTION_DOWN: initlization (); break; case MotionEvent. ACTION_UP: if (event. getY ()
/*** {@ Link # RecordButton} required tool class ** @ author kymjs (kymjs123@gmail.com) */public class RecordButtonUtil {public static final String AUDOI_DIR = Environment. getExternalStorageDirectory (). getAbsolutePath () + "/oschina/audio"; // The root path of the audio recording file private String mAudioPath; // the path of the audio to be played private boolean mIsRecording; // whether the recording is
/** The application needs to have the permission to write to external storage * If the output file is written to the external storage, and also the * permission to record audio. these permissions must be set in the * application's androidmanifest. XML file, with something like: ** **/package COM. android. audiorecordtest; import android. app. activity; import android. widget. linearlayout; import android. OS. bundle; import android. OS. environment; import android. view. viewgroup; import andro
Android multimedia audio and video recording MediaRecorderOverview:
MediaRecorder status chart:Initial: Initial state. When a MediaRecorder object is created using the new () method or the reset () method is called, The MediaRecZ prepare? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> vcmRlcrbUz/examples/templates + SW5pdGlhbGl6ZWSjutLRs/templates + templates/ release/bOxLz + release/Uyr61yLXIoaO/release + release/L/release + LP2tcS0yr3Q1/ZJZGxlIHN0YXRlIL/release + rele
Android camera uses ISO values to record videoMy application is to use a custom camera to record a video on an LED light box, the frequency of the LED is 1000HZ, and I use a high ISO value recording, the final desired effect, such as the screen will appear in the visible black stripes .To achieve this effect, set the following settings for the camera's parameters: "Code 1"P. Setscenemode(Camera. Parameters. SCENE_mode_auto);P. setantibanding(Camera. Parameters. Antibanding_auto);P. Setfocusmode(
);
Mr.setaudioencoder (MediaRecorder.AudioEncoder.AMR_NB);
Mr.setmaxduration (10000);
Mr.setoutputfile (Environment.getexternalstoragedirectory (). GetPath () +file.separator+"fisii77s.3gp");
Mr.prepare ();
Mr.start ();
I believe everyone is doing this, the key is that we have a layer of if (mr==null) judgment in front of theI wrote this before the error in the code:[Java]View PlainCopy
"FONT-SIZE:18PX;" > public void Start (context context, String name) {
if (
Package Com.k1.doctor.media;import Java.io.file;import java.io.ioexception;import java.util.uuid;import Android.media.mediarecorder;import Android.os.environment;import Android.os.Handler; Public classAudiomanager {PrivateMediarecorder Mrecorder; PrivateString mdirstring; PrivateString mcurrentfilepathstring; PrivateBoolean isprepared;//Are you ready for this ? /** * Singleton Method 1 First declare a static type of variable a 2 in the declaration
Objective:In fact, recording in Android can be recorded with Mediarecord, the operation is relatively simple. However, the audio cannot be processed. Consider that the project is done in real-time voice can only select Audiorecord for recording.This article is a review of Audiorecord: Public classAudiorecordmanager { Public Static FinalString TAG = "Audiorecordmanager"; PrivateAudiorecord Mrecorder; PrivateDataOutputStream dos; PrivateThread Recordthr
buttons on the interface ImageButton record, stop;//the system's audio file soundfile; Mediarecorder mrecorder; @Overridepublic void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate ); Setcontentview (r.layout.main);//Get two buttons in the program interface record = (ImageButton) Findviewbyid (r.id.record); stop = (ImageButton) Findviewbyid (r.id.stop);//Click event Binding Listener Record.setonclicklistener (this) for two bu
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.